/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.casestudy1.bus;

import com.casestudy1.main.MainMidlet;
import com.casestudy1.view.LinearGradientPainter;
import com.casestudy1.view.LoginForm;
import com.sun.lwuit.Button;
import com.sun.lwuit.Command;
import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.Label;
import com.sun.lwuit.animations.CommonTransitions;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BoxLayout;
import com.sun.lwuit.plaf.Style;

/**
 *
 * @author PC
 */
public class SearchBus extends Form {
    
    private Button btSearchStreet;
    private Button btSearchNumber;
    private Button btBack;
    private Button btLogout;
    private Button btExit;
    private LoginForm loginform;
    private Command cmBack;
    private Command cmSelect;
    private Label lbSpace;

    public SearchBus(final MainMidlet midlet) {
        super("Search");
        Style titlestyle = new Style();
        titlestyle.setAlignment(CENTER);
        titlestyle.setBgPainter(new LinearGradientPainter(0, 0xffffff, false));
        setTitleStyle(titlestyle);
        getStyle().setBgPainter(new LinearGradientPainter( 0x330000, 0xFF0000, false));
        setLayout(new BoxLayout(BoxLayout.Y_AXIS));

        setTransitionOutAnimator(CommonTransitions.createSlide(
                CommonTransitions.SLIDE_HORIZONTAL, true, 1000));

        btSearchStreet = new Button("Tim kiem theo duong pho");
        btSearchStreet.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                midlet.showSearchStreet();
            }
        });
        btSearchNumber = new Button("Tim kiem theo so xe");
        btSearchNumber.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent ae) {
                midlet.showSearchNumber();
            }
        });
        
        btBack = new Button("Quay lai menu chinh");
        btBack.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                midlet.showMainMenu();
            }
        });
        
        btLogout = new Button("Logout");
        btLogout.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent ae) {
                LoginForm lf = new LoginForm(null);
                lf.show();
            }
        });
        
        btExit = new Button("Thoat");
        btExit.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent ae) {
                Display.getInstance().exitApplication();
            }
        });
        cmBack = new Command("Back") {
            public void actionPerformed(ActionEvent evt) {
                midlet.showMainMenu();
            }
        };

        cmSelect = new Command("Select");
        lbSpace = new Label("");

        addComponent(lbSpace);
        addComponent( btSearchStreet);
        addComponent( btSearchNumber);
        addComponent( btBack);
        addComponent(btLogout);
        addComponent(btExit);
        addCommand(cmBack);
        addCommand(cmSelect);

    }
}
